@extends('default.layouts.adminPublic')
@section('title', '地区管理列表')

@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/admin/category.css')}}">
    @endsection
    @section('content')

            <!--导航开始-->
    <div class="crumb_warp">
        <i class="fa fa-home"></i> <a href="{{url('admin/coll_area')}}">首页</a> &raquo; 地区管理
    </div>
    <!--导航结束-->

    <div class="con">
        <div class="manage">@include('flash::message')</div>
        <div class="conMain">
            <div class="cLeft">
                <div class="cTitle"><a href="{{url('admin/coll_area/create')}}"><i class="fa fa-list-ul"></i>添加省份管理</a>
                </div>
                <div class="cateList listScroll">
                    <ul>
                        @if(count($province)>0)
                            @foreach($province as $v)
                                <li id="active{{$v->pid}}"><a href="{{url('admin/coll_area/'.$v->pid)}}"><i class="fa fa-fw fa-folder-open"></i>{{msubstr(trim($v->name),0,4)}}</a></li>
                            @endforeach
                        @else
                            <li><a><i class="fa fa-fw fa-ban"></i>列表为空</a></li>
                        @endif
                    </ul>
                </div>
            </div>
            <div class="cRight">
                <div class="list">
                    @if(empty($provinceList))
                        <div class="cTitle cTitleList"><i class="fa fa-folder" style="color: #333"></i>请选择地区管理</div>
                    @else
                        <div class="cTitle cTitleList"><i class="fa fa-folder" style="color: #333"></i>当前选择：{{$provinceList->name}}</div>
                    @endif
                    <div class="listBox">
                        <div class="listCon listScroll">
                            <ul>
                                <li class="optColl">
                                    <div class="options one">
                                        <dl>
                                            <dt class="opt_sort">地区排序</dt>
                                            <dd class="opt_name" style="color: #333">地区名称</dd>
                                            <dd class="opt_name" style="color: #333">英文地区名称</dd>
                                            <dd class="opt_id">地区编码</dd>
                                            <dd class="operating">操作</dd>
                                        </dl>
                                    </div>
                                </li>
                                {{--选择省份--}}
                                @if(empty($provinceList))
                                    <li>请选择管理地区</li>
                                @else
                                <li>
                                    <div class="options optBefore">
                                        <dl>
                                            <dt class="opt_sort" id="oSort">{{$provinceList->sort}}</dt>
                                            <dd class="opt_name nameColor" id="oName">{{$provinceList->name}}</dd>
                                            <dd class="opt_name nameColor" id="oEnName">{{$provinceList->en_name}}</dd>
                                            <dd class="opt_id" id="oCid">{{$provinceList->cid}}</dd>
                                            <dd class="operating">
                                                <input type="submit" value="编辑"  onclick="editOpt(this)" class="sub"  id="editOpt"/>
                                                <input type="button" value="删除"  onclick="delOptions(this,'{{$provinceList->id}}','{{$provinceList->grade}}')" class="sub but" id="delOpt"/>
                                                <input type="button" value="添加"  onclick="addOptions(this,'{{$provinceList->cid}}','2')" class="sub" id="addOpt"/>
                                            </dd>
                                        </dl>
                                    </div>

                                    <div class="options optAfter disNone">
                                        <form action="" method="post" name="updateForm" id="updateForm" onsubmit="return false">
                                            {{csrf_field()}}
                                            <input name="id" value="{{$provinceList->id}}" type="hidden"/>
                                            <input name="pid" value="{{$provinceList->pid}}" type="hidden"/>
                                            <input name="grade" value="{{$provinceList->grade}}" type="hidden"/>
                                            <dl>
                                                <dt class="opt_sort"><input name="sort" id="sort"  value="{{$provinceList->sort}}" class="opt sort" type="text" placeholder=""/></dt>
                                                <dd class="opt_name"><input name="name" id="name" value="{{$provinceList->name}}" class="opt"  type="text" placeholder="请输入省份名称"/></dd>
                                                <dd class="opt_name"><input name="en_name" id="en_name" value="{{$provinceList->en_name}}" class="opt"  type="text" placeholder="请输入英文省份名称"/></dd>
                                                <dd class="opt_id"><input name="cid" id="cid" value="{{$provinceList->cid}}" class="opt" type="text" placeholder="请输入正确的编码"/></dd>
                                                <dd class="operating">
                                                    <input type="submit" value="保存"  onclick="updateOption(this,'{{url('admin/coll_area/'.$provinceList->id)}}','1')" class="sub" id="saveOpt"/>
                                                    <input type="button" value="取消" onclick="cancelOption(this)" class="sub but" id="cancelOpt"/>
                                                </dd>
                                            </dl>
                                        </form>
                                    </div>
                                </li>
                                @if(count($provinceList->area)>0)
                                    @foreach($provinceList->area as $v)
                                        <li>
                                            <div class="options optBefore">
                                                <dl>
                                                    <dt class="opt_sort" id="oSort">{{$v->sort}}</dt>
                                                    <dd class="opt_name nameColor" id="oName">{{$v->html}}{{$v->name}}</dd>
                                                    <dd class="opt_name nameColor" id="oEnName">@if(!empty($v->en_name)){{$v->html}}{{$v->en_name}}@endif</dd>
                                                    <dd class="opt_id" id="oCid">{{$v->cid}}</dd>
                                                    <dd class="operating">
                                                        <input type="submit" value="编辑"  onclick="editOpt(this)" class="sub"  id="editOpt"/>
                                                        <input type="button" value="删除"  onclick="delOptions(this,'{{$v->id}}','2')" class="sub but" id="delOpt"/>
                                                        <input type="button" value="添加"  onclick="addOptions(this,'{{$v->cid}}','3')" class="sub" id="addOpt"/>
                                                    </dd>
                                                </dl>
                                            </div>

                                            <div class="options optAfter disNone">
                                                <form action="" method="post" name="updateForm" id="updateForm" onsubmit="return false">
                                                    {{csrf_field()}}
                                                    <input name="id" value="{{$v->id}}" type="hidden"/>
                                                    <input name="pid" value="{{$v->pid}}" type="hidden"/>
                                                    <input name="grade" value="{{$v->grade}}" type="hidden"/>
                                                    <dl>
                                                        <dt class="opt_sort"><input name="sort" id="sort"  value="{{$v->sort}}" class="opt sort" type="text"/></dt>
                                                        <dd class="opt_name"><input name="name" id="name" value="{{$v->name}}" class="opt"  type="text" placeholder="请输入地区名称" /></dd>
                                                        <dd class="opt_name"><input name="en_name" id="en_name" value="{{$v->en_name}}" class="opt"  type="text" placeholder="请输入英文地区名称" /></dd>
                                                        <dd class="opt_id"><input name="cid" id="cid" value="{{$v->cid}}" class="opt" type="text" placeholder="请输入正确的编码" /></dd>
                                                        <dd class="operating">
                                                            <input type="submit" value="保存"  onclick="updateOption(this,'{{url('admin/coll_area/'.$v->id)}}','2')" class="sub" id="saveOpt"/>
                                                            <input type="button" value="取消" onclick="cancelOption(this)" class="sub but" id="cancelOpt"/>
                                                        </dd>
                                                    </dl>
                                                </form>
                                            </div>
                                        </li>
                                        @foreach($v->city as $vv)
                                            <li>
                                                <div class="options optBefore">
                                                    <dl>
                                                        <dt class="opt_sort" id="oSort">{{$vv->sort}}</dt>
                                                        <dd class="opt_name nameColor" id="oName">{{$vv->html}}{{$vv->name}}</dd>
                                                        <dd class="opt_name nameColor" id="oEnName">@if(!empty($vv->en_name)){{$vv->html}}{{$vv->en_name}}@endif</dd>
                                                        <dd class="opt_id" id="oCid">{{$vv->cid}}</dd>
                                                        <dd class="operating">
                                                            <input type="submit" value="编辑"  onclick="editOpt(this)" class="sub"  id="editOpt"/>
                                                            <input type="button" value="删除"  onclick="delOptions(this,'{{$vv->id}}','3')" class="sub but" id="delOpt"/>
                                                        </dd>
                                                    </dl>
                                                </div>

                                                <div class="options optAfter disNone">
                                                    <form action="" method="post" name="updateForm" id="updateForm" onsubmit="return false">
                                                        {{csrf_field()}}
                                                        <input name="id" value="{{$vv->id}}" type="hidden"/>
                                                        <input name="pid" value="{{$vv->pid}}" type="hidden"/>
                                                        <input name="grade" value="{{$vv->grade}}" type="hidden"/>
                                                        <dl>
                                                            <dt class="opt_sort"><input name="sort" id="sort"  value="{{$vv->sort}}" class="opt sort" type="text"/></dt>
                                                            <dd class="opt_name"><input name="name" id="name" value="{{$vv->name}}" class="opt"  type="text" placeholder="请输入城市名称"/></dd>
                                                            <dd class="opt_name"><input name="en_name" id="en_name" value="{{$vv->en_name}}" class="opt"  type="text" placeholder="请输入英文城市名称"/></dd>
                                                            <dd class="opt_id"><input name="cid" id="cid" value="{{$vv->cid}}" class="opt" type="text" placeholder="请输入正确的编码" /></dd>
                                                            <dd class="operating">
                                                                <input type="submit" value="保存"  onclick="updateOption(this,'{{url('admin/coll_area/'.$vv->id)}}','3')" class="sub" id="saveOpt"/>
                                                                <input type="button" value="取消" onclick="cancelOption(this)" class="sub but" id="cancelOpt"/>
                                                            </dd>
                                                        </dl>
                                                    </form>
                                                </div>
                                            </li>
                                        @endforeach
                                    @endforeach
                                @endif
                               @endif
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('footerjs')
    @parent
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.form.js')}}"></script>
    <script type="text/javascript">
        var _token = "{{csrf_token()}}";
        var csrf_field = '{{csrf_field()}}';
        var areaUrl = "{{url('admin/coll_area')}}";

        var pid = '{{$pid or ''}}';
        if(pid != '')  $('#active'+pid).addClass('active');
    </script>
    <script type="text/javascript" src="{{asset('/default/js/admin/area.js')}}"></script>
@endsection